# def funa(step):
#     n = 1
#     n+=step
#     print(n)
#
# # funa(10)
# for i in range(5):
#     funa(10)

# 保存局部变量不被销毁(每次n=1) n=1保存 n=1 1+10=11保存 11+10=21保存 21+10=31
def outer(step):
    n = 1
    def inner():
        nonlocal n
        n+=step
        print(n)
    return inner

# 保证只执行一次外部函数
ot = outer(10)
# 累加(累积)
for i in range(5):
    ot()
print("------------------")
ot2 = outer(10)
ot2()